home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
drum_ed.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
4KB
|
132 lines
/*
* EKED-M1 : Editor for Korg M1 synth; drum_ed.c : drum editor
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <string.h>
#include <gemfast.h>
#include <aesbind.h>
#include "gm/gem_man.h"
#include "eked-m1.h"
#include "defs.h"
#include "types.h"
#include "externs.h"
typedef struct {
int ob_number;
PARA_TYPE type;
} DPARAMETER;
#define DT_SIZE 6
static DPARAMETER drum_table[] =
{
{D_SOUND, DSND},
{D_KEY, DKEY},
{D_PAN, CPAN},
{D_TUNE, S120},
{D_LEVEL, SN50},
{D_DECAY, SN50}
};
OBJECT *drum;
OBJECT *drum_head;
static void display(int x_pos, int y_pos, GRECT *clip, long usr_val);
static int action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val);
int de_window(char *title, BYTE *kit)
{
int t;
rm_gaddr(R_TREE, DRUM, &drum);
rm_gaddr(R_TREE, DRUM_HEAD, &drum_head);
t = wm_open(NAME | CLOSER | FULLER | MOVER | SIZER |
UPARROW | DNARROW | VSLIDE |
LFARROW | RTARROW | HSLIDE,
(GRECT *) 0, title,
drum[0].ob_width, 31 * drum[0].ob_height,
char_w, drum[0].ob_height, &display, &action, (long) kit);
if(t < 0){
fm_alert(1, WINDOW_ALERT);
return 0;
}
return t;
}
static void display(int x_pos, int y_pos, GRECT *clip, long usr_val)
{
int i, j, e, h = drum[0].ob_height;
BYTE *data;
i = (clip->g_y - y_pos) / h - 1;
if(i < 0){
i = 0;
drum_head[0].ob_x = x_pos;
drum_head[0].ob_y = y_pos;
objc_draw(drum_head, 0, MAX_DEPTH,
clip->g_x, clip->g_y, clip->g_w, clip->g_h);
}
e = (clip->g_y + clip->g_h - 1 - y_pos) / h - 1;
if(e >= 0){
drum[0].ob_x = x_pos;
drum[0].ob_y = y_pos + i * h;
data = ((BYTE *) usr_val) + i * 7;
for(; i <= e; i++){
drum[0].ob_y += h;
((char *) drum[D_NUMBER].ob_spec)[0] = '0' + i / 10;
((char *) drum[D_NUMBER].ob_spec)[1] = '0' + i % 10;
for(j = 0; j < DT_SIZE; j++)
para_fill(drum + drum_table[j].ob_number, drum_table[j].type, data++);
data++;
objc_draw(drum, 0, MAX_DEPTH,
clip->g_x, clip->g_y, clip->g_w, clip->g_h);
}
}
}
static int action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val)
{
int i, j, h = drum[0].ob_height, m_x, m_y, ob;
switch(type){
case E_CLEANUP:
ge_drumexit(handle);
break;
case E_CLICK:
m_x = ((CLICK *) event)->m_x;
m_y = ((CLICK *) event)->m_y;
i = (m_y - y_pos) / h;
if(i == 0)
break;
drum[0].ob_x = x_pos;
drum[0].ob_y = y_pos + h * i;
ob = objc_find(drum, 0, MAX_DEPTH, m_x, m_y);
for(j = 0; j < DT_SIZE; j++){
if(drum_table[j].ob_number == ob){
para_edit(handle, drum, ob, drum_table[j].type, -1, -1,
((BYTE *) usr_val) + (i - 1) * 7 + j);
break;
}
}
break;
}
return R_NORMAL;
}